package dao.pojo;

import java.util.HashSet;
import java.util.Set;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import static javax.persistence.GenerationType.IDENTITY;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * CommodityCategory entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "commodity_category", catalog = "onlinemall")
public class CommodityCategory implements java.io.Serializable {

	// Fields

	private Integer commodityCategoryId;
	private CommodityCategory commodityCategory;
	private String commodityCategoryName;
	private Set<CommodityCategory> commodityCategories = new HashSet<CommodityCategory>(
			0);
	private Set<CommodityInfo> commodityInfos = new HashSet<CommodityInfo>(0);

	// Constructors

	/** default constructor */
	public CommodityCategory() {
	}

	/** minimal constructor */
	public CommodityCategory(CommodityCategory commodityCategory,
			String commodityCategoryName) {
		this.commodityCategory = commodityCategory;
		this.commodityCategoryName = commodityCategoryName;
	}

	/** full constructor */
	public CommodityCategory(CommodityCategory commodityCategory,
			String commodityCategoryName,
			Set<CommodityCategory> commodityCategories,
			Set<CommodityInfo> commodityInfos) {
		this.commodityCategory = commodityCategory;
		this.commodityCategoryName = commodityCategoryName;
		this.commodityCategories = commodityCategories;
		this.commodityInfos = commodityInfos;
	}

	// Property accessors
	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "commodity_category_id", unique = true, nullable = false)
	public Integer getCommodityCategoryId() {
		return this.commodityCategoryId;
	}

	public void setCommodityCategoryId(Integer commodityCategoryId) {
		this.commodityCategoryId = commodityCategoryId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "parent_commodity_category_id", nullable = false)
	public CommodityCategory getCommodityCategory() {
		return this.commodityCategory;
	}

	public void setCommodityCategory(CommodityCategory commodityCategory) {
		this.commodityCategory = commodityCategory;
	}

	@Column(name = "commodity_category_name", nullable = false, length = 30)
	public String getCommodityCategoryName() {
		return this.commodityCategoryName;
	}

	public void setCommodityCategoryName(String commodityCategoryName) {
		this.commodityCategoryName = commodityCategoryName;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "commodityCategory")
	public Set<CommodityCategory> getCommodityCategories() {
		return this.commodityCategories;
	}

	public void setCommodityCategories(
			Set<CommodityCategory> commodityCategories) {
		this.commodityCategories = commodityCategories;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "commodityCategory")
	public Set<CommodityInfo> getCommodityInfos() {
		return this.commodityInfos;
	}

	public void setCommodityInfos(Set<CommodityInfo> commodityInfos) {
		this.commodityInfos = commodityInfos;
	}

}